<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>绑定样式</title>
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
<script src="vue.js"></script>
<style>
    .basic {
            width: 400px;
            height: 100px;
            border: 1px solid black;
    }
    .happy{
        background-image: linear-gradient(180deg, rgb(247, 132, 132), rgb(241, 241, 80));
    }
    .sad{
        background-color: gray;
            border: 3px dashed green;
    }
    .normal{
        background-color: skyblue;
    }
    .atguigu1{
        background-color: rgb(140, 244, 195);
    }
    .atguigu2{
        font-size: 50px;
        text-shadow: 2px 2px 5px red;
    }
    .atguigu3{
        border-radius: 20px;
        background-color: yellow
    }
</style>
</head>
<body>
    <div id="root">
        <!-- 绑定class样式 -->
        <div class="basic" :class="custCls" @click="changeMood()">{{name}}</div>
        
        <div class="basic" :class="arr">{{name}}</div>
        
        <div class="basic" :class="classObj">{{name}}</div>
        
        <div class="basic" :style="styleObj">{{name}}</div>
    </div>
   <script type="text/javascript">
    new Vue({
        el:'#root',
        data: {
            name:'学习',
            custCls:'',
            arr:['atguigu1','atguigu2','atguigu3'],
            classObj:{atguigu1:true, atguigu2:false},
            styleObj:{fontSize: '40px'}
        },
        methods: {
            changeMood() {
                const arr = ["happy","sad","normal"]
                this.custCls = arr[Math.floor(Math.random() * 3)]
            }
        },
    })
   </script>
</body>
</html>